<!DOCTYPE html>
<html>
	<head>
	    <meta charset="utf-8">
	    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
	    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
	    <title>Hello APP</title>
	    <link rel="stylesheet" type="text/css" href="../../../css/index.css" />
	</head>
	<style type="text/css">
		html,body{background: #f5f5f5商品;}
		.warp{width: 100%;}
		input::-webkit-input-placeholder{color: #BDBDBD;font-size: 14px;}
		input::-moz-placeholder{color: #BDBDBD;font-size: 14px;}

		#header{position:fixed;width: 100%;height: 48px;background: #FFFFFF;z-index: 99;left: 0;top: 0;}
		#header .search-box{width: 100%;height: 48px;background: #FFFFFF;align-items: center;justify-content: center;}
		#header .search-box .go-back{flex-shrink: 0;align-items:center;justify-content: center;padding: 0 8px 0 15px;}
		#header .search-box .go-back img{display: block;width: 22px;height: 22px;}
		#header .search-box .search{height: 30px;border-radius:16px;padding-left:34px;box-sizing: border-box;background: url(../../../image/main0/search_bg.png) no-repeat left 9px center #F3F5F5;background-size: 14px;}
		#header .search-box .search input{font-size: 14px;}
		#header .search-box .search .del{width: 30px;height: 30px;align-items:center;justify-content: center;}
		#header .search-box .search .del img{width: 16px;height: 16px;}
		#header .search-box .btn{flex-shrink: 0;padding: 0 15px;font-size: 15px;color: #4D4F50;}

		.info-box{width: 100%;background: #FFFFFF;padding-left: 15px ;box-sizing: border-box;}
		.info-box .title{align-items: center;justify-content: space-between;height: 50px;}
		.info-box .title .text{font-size: 14px;color: #333333;}
		.info-box .title .del{width: 50px;height: 50px;align-items:center;justify-content: center;}
		.info-box .title .del img{width: 16px;height: 16px;}
		.info-box .list{flex-wrap: wrap;padding-right: 15px;}
		.info-box .list span{display: block;padding: 0 20px;font-size: 12px;margin-right: 10px;margin-bottom: 12px;box-sizing: border-box;height: 32px;text-align: center;line-height: 32px;border-radius:16px;color: #333333;}
		.info-box .list span::before{border-radius: 30px;}
		.pop-info{position: fixed;top: 0;left: 0;bottom: 0;right: 0;background: #F6F6F6;padding-top: 10px;width: 100%;height: 100%;box-sizing: border-box;}
		.pop-info .pop-box{width: 100%;}
		.pop-info .pop-box .pop-one{height: 50px;line-height: 50px;padding-left: 15px;background: #FFFFFF;}
		.pop-info .pop-box .pop-one:last-child:before{display: none;}


		.kind_box .right{width: 100%;background: #F7F7F7;padding-top: 10px;}
        .kind_box .right .goods{width: 100%;margin-bottom: 10px;}
        .kind_box .right .goods:last-child{margin-bottom: 80px;}
        .kind_box .right .goods .sel{width: 46px;background: url(../../../image/main2/sel_icon0.png) no-repeat center;background-size:18px;}
        .kind_box .right .goods .sel.on{background: url(../../../image/main2/sel_icon1.png) no-repeat center;background-size:18px;}
        .kind_box .right .goods .info-box{background: #ffffff;padding:0 15px;box-sizing: border-box;}
        .kind_box .right .goods .info-box .top{padding: 10px 0;}
        .kind_box .right .goods .info-box .top .img-box{width: 70px;height: 70px;}
        .kind_box .right .goods .info-box .top .img-box img{width:100%;height:100%;}

        .kind_box .right .goods .info-box .top .info{padding-left: 10px;}
        .kind_box .right .goods .info-box .top .info .name{font-size: 14px;}
        .kind_box .right .goods .info-box .top .info .guige{font-size: 12px;color: #999999;padding-top: 4px;height: 18px;}
        .kind_box .right .goods .info-box .top .info .other{align-items: center;padding-top: 10px;}
        .kind_box .right .goods .info-box .top .info .other .price{font-size: 16px;color: #FF9502;font-weight: bold;}
        .kind_box .right .goods .info-box .top .info .other .code{font-size: 15px;line-height: 16px;color: #FF9502;font-weight: bold;flex-shrink: 0;}
        .kind_box .right .goods .info-box .top .info .other .code .z{font-size: 13px}
        .kind_box .right .goods .info-box .top .info .other .num{font-size: 12px;color: #999999;text-align: right;}

        .kind_box .right .goods .info-box .bot{}
        .kind_box .right .goods .info-box .bot .sta1{height: 42px;font-size: 12px;align-items: center;justify-content: flex-end;}
        .kind_box .right .goods .info-box .bot .sta1 .btn{align-items: center;justify-content: center;width: 33.3%;}
        .kind_box .right .goods .info-box .bot .sta1 .edit span{background: url(../../../image/main3/addr_icon1.png) no-repeat left center;background-size:14px;padding-left: 20px;}
        .kind_box .right .goods .info-box .bot .sta1 .del span{background: url(../../../image/main3/addr_icon2.png) no-repeat left center;background-size:14px;padding-left: 20px;}
        .kind_box .right .goods .info-box .bot .sta1 .xiajia span{background: url(../../../image/main3/addr_icon3.png) no-repeat left center;background-size:14px;padding-left: 20px;}
        .kind_box .right .goods .info-box .bot .sta1 .shangjia span{background: url(../../../image/main3/addr_icon4.png) no-repeat left center;background-size:14px;padding-left: 20px;}
        .kind_box .right .goods .info-box .bot .sta1 .ge{height: 14px;}

        .kind_box .right .goods .info-box .bot .sta2{height: 42px;font-size: 12px;align-items: center;justify-content: space-between;}
        .kind_box .right .goods .info-box .bot .sta2 .qiang{font-size: 14px;color: #F13A3B;}
        .kind_box .right .goods .info-box .bot .sta2 .del{}
        .kind_box .right .goods .info-box .bot .sta2 .del span{background: url(../../../image/main3/addr_icon2.png) no-repeat left center;background-size:14px;padding-left: 20px;}


	</style>
	<body>
		<div id="vue" class="warp">

			<div id="header" >
				<div class="search-box flex">
					<div class="go-back" tapmode onclick="backMenu(this);"><img src="../../../image/main/back.png"/></div>
					<div class="search flex1 flex">
						<input class="flex1" type="text" id="keyword" onfocus="showList()" onblur="closeList()" oninput="inputText()" placeholder="搜索商品关键词"/>
						<div class="del flex" tapdome onclick="closeSearch()" style="display:none;"><img src="../../../image/main3/del-img.png"/></div>
					</div>
					<div class="btn" tapmode onclick="goShopList(this);">搜索</div>
				</div>
			</div>
			<div class="zhanwei" style="width: 100%"></div>

			<!-- 商品列表 -->
			<div class="kind_box">
	            <div class="right">

	                <div class="goods flex" v-for="(item,key) in Pdata.listData">
	                    <div class="sel" :style="{ display:(edit == 1 ? '':'none')}" :data-id="item.id" :data-sta="item.forced_down" tapmode onclick="selone(this)"></div>
	                    <div class="info-box flex1">
	                        <div class="top flex" :data-id="item.id" tapmode onclick="goodshow(this)">
	                            <div class="img-box"><img :src="item.image"></div>
	                            <div class="info flex1">
	                                <div class="name han_1" v-text="item.title"></div>
	                                <div class="guige"></div>
	                                <div class="other flex">
	                                    <div class="price">¥<i v-text="item.price"></i></div>
	                                    <div v-if="item.unscore" class="code">+<i v-text="item.unscore"></i><i class="z">积分</i></div>
	                                    <div class="num flex1">库存<i v-text="item.ku_num"></i></div>
	                                </div>
	                            </div>
	                        </div>
	                        <div class="bot">
	                            <div class="sta1 flex border-top" :style="{ display:(edit == 0 && item.forced_down == 0 ? '':'none')}">
	                                <div class="btn edit flex" v-if="item.isjia == 0" :data-id="item.id" tapmode onclick="goodsEdit(this)"><span>编辑</span></div>
	                                <div class="ge border-right" v-if="item.isjia == 0"></div>
	                                <div class="btn del flex" data-type="one" :data-id="item.id" tapmode onclick="goodsDel(this)"><span>删除</span></div>
	                                <div class="ge border-right"></div>
	                                <div class="btn xiajia flex" v-if="item.isjia == 1" data-type="one" :data-id="item.id" tapmode onclick="goodsJia(this)"><span>下架</span></div>
	                                <div class="btn shangjia flex" v-if="item.isjia == 0" data-type="one" :data-id="item.id" tapmode onclick="goodsUp(this)"><span>上架</span></div>
	                            </div>
	                            <div class="sta2 flex border-top" :style="{ display:(item.forced_down == 1 ? '':'none')}">
	                                <div class="qiang">强制下架</div>
	                                <div class="del" data-type="one" :data-id="item.id" tapmode onclick="goodsDel(this)"><span>删除</span></div>
	                            </div>
	                        </div>
	                    </div>
	                </div>

	                <!--占位图-->
	                <div class="nodata" style="display:none;" :style="{ display:(noData ? '':'none')}">
	                    <img src="../../../image/no_page/no_shop.png" />
	                    <p>暂无搜索商品</p>
	                </div>

	            </div>
			</div>
		</div>
	</body>
</html>
<script type="text/javascript" src="../../../script/base.min.js" id="loadjs" data-js="L/swiper.min,L/lazyload,L/h-tool"></script>
<script type="text/javascript">
	var _top = lanYun.setHeader('header');
	$('.zhanwei').height(_top);

	define(function (require, exports, module) {

		var stype = pageParam.type;
		var keyword = '';
		var url = {
			"shop":{
                "list":'store/Goods/index',
                "up":'store/Goods/upJia',
                "down":'store/Goods/downJia',
                "del":'store/Goods/del',
                "show":'store/Goods/show'
            },
            "jifen":{
                "list":'store/ScoreGoods/index',
                "up":'store/ScoreGoods/upJia',
                "down":'store/ScoreGoods/downJia',
                "del":'store/ScoreGoods/del',
                "show":'store/ScoreGoods/show'
            },
		}

		_page.getData = function(loading) {
			lanYun.getVueData({url:url[stype].list,get:{page:lanYun.page,keyword:keyword},cache:false,loading:loading},function(ret) {
				//console.log(JSON.stringify(ret));
			});
		};

		//创建vue
		lanYun.newVue('#vue',{
			showList:0,
			edit:0,
            isjia:2,
			Pdata:{
				listData:[]
			}
		}, function() {

		});

		// 点击搜索
		goShopList = function (){
			var key = $('#keyword').val();
			if(!key){
				lanYun.toast('请输入关键词');
				return;
			}
			keyword = key;
	        intGetData();
		}

		inputText = function () {
			var keyword = $('#keyword').val();
			if(keyword.length > 0){
				$('.del').show();
			}else {
				$('.del').hide();
			}
		}

		// 批量删除商品
        goodsDel = function (tis) {
            var dst = tis.dataset;
            var sids = [];
            if(dst.type == 'more'){
                $(".right .on").each(function() {
                    sids.push(this.dataset.id);
                });
                if(sids.length <= 0){
                    lanYun.toast('请选择删除商品');
                    return;
                }
            }else {
                sids.push(dst.id);
            }
            lanYun.alert({fname:'diaLogBox1',title:'提示', button:['取消','确定'],content: '您确定要删除商品吗？'},function(ret){
	            if (ret.index == 0) return;
				lanYun.post(url[stype].del,{ids:sids},function (ret){
					lanYun.toast(ret.msg);
					if(ret.errcode == 0){
                        intGetData();
						lanYun.setStorage('reshpage',1);
					}
				},2)
	        });
        }

		// 批量下架商品
        goodsJia = function (tis) {
            var dst = tis.dataset;
            var sids = [];
            if(dst.type == 'more'){
                $(".right .on").each(function() {
                    sids.push(this.dataset.id);
                });
                if(sids.length <= 0){
                    lanYun.toast('请选择下架商品');
                    return;
                }
            }else {
                sids.push(dst.id);
            }
            lanYun.alert({fname:'diaLogBox1',title:'提示', button:['取消','确定'],content: '您确定要下架商品吗？'},function(ret){
	            if (ret.index == 0) return;
				lanYun.post(url[stype].down,{ids:sids},function (ret){
					lanYun.toast(ret.msg);
					if(ret.errcode == 0){
                        intGetData();
						lanYun.setStorage('reshpage',1);
					}
				},2)
	        });
        }

        // 批量上架商品
        goodsUp = function (tis) {
            var dst = tis.dataset;
            var sids = [];
            if(dst.type == 'more'){
                $(".right .on").each(function() {
                    sids.push(this.dataset.id);
                });
                if(sids.length <= 0){
                    lanYun.toast('请选择上架商品');
                    return;
                }
            }else {
                sids.push(dst.id);
            }
            lanYun.alert({fname:'diaLogBox1',title:'提示', button:['取消','确定'],content: '您确定要上架商品吗？'},function(ret){
	            if (ret.index == 0) return;
				lanYun.post(url[stype].up,{ids:sids},function (ret){
					lanYun.toast(ret.msg);
					if(ret.errcode == 0){
                        intGetData();
						lanYun.setStorage('reshpage',1);
					}
				},2)
	        });
        }

		// 搜索关联词类表
		showList = function (){
			lanYun.vue.showList = 1;
		}
		closeList = function () {
			lanYun.vue.showList = 0;
		}

		//页面关闭方法
		backMenu = function backMenu(tis){
			api.closeWin();
		}

		//清空搜索
		closeSearch = function(){
			$('#keyword').val('');
			$('.del').hide();
			lanYun.vue.Pdata.listData = [];
		}

		//编辑商品商品
	    goodsEdit = function (tis) {
	        var dst = tis.dataset;
            var winName = api.winName;
            var frameName = api.frameName;
	        lanYun.openWin('main3/store/goods_edit.html', {
	            win:'win',
                title:'编辑商品',
	            frameParam : {id:dst.id,type:stype,winName:winName,frameName:frameName}
	        });
	    }

		//打开商品详情
		goodshow = function (tis) {
			var dst = tis.dataset;
			lanYun.openWin('main3/store/goods_show.html', {
				win:'win',
				title:'商品详情',
				frameParam : {id:dst.id,type:stype}
			});
		}

		// 刷新页面
		intGetData = function () {
			lanYun.ajaxPageSta = 0; lanYun.page = 1;
			_page.getData(2);
		}
	});
</script>
